<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
  <title>栏目添加</title>
  <meta name="decorator" content="default"/>
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="栏目添加" />
    <div class="page-content">
        <form:form id="inputForm" modelAttribute="category" action="" method="post" class="form-horizontal">
            <form:hidden path="id"/>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">上级栏目:</label>
                <div class="col-md-4">
                    <tags:treeselect id="parent" name="parent.id" value="${category.parent.id}" labelName="parent.name" labelValue="${category.parent.name}"
                             title="上级栏目" url="/cms/category/treeData?type=1" selectIds="${category.parent.id}" cssClass="required col-sm-9"/>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">栏目模型:</label>
                <div class="col-md-4">
                    <form:select path="module">
                        <form:option value="" label="公共模型"/>
                        <form:options items="${fns:getDictList('cms_module')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                    </form:select>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">中文名称:</label>
                <div class="col-md-4">
                    <form:input path="name" htmlEscape="false" maxlength="50" class="col-md-9 required"/>
                </div>
                <label class="col-md-2 no-padding-right control-label">英文名称:</label>
                <div class="col-md-4">
                    <form:input path="enname" htmlEscape="false" maxlength="50" class="col-md-9 required"/>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">缩略图:</label>
                <div class="col-md-8">
                    <form:input path="image" htmlEscape="false" maxlength="255" class="col-md-4"/>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">链接:</label>
                <div class="col-md-8">
                    <form:input path="href" htmlEscape="false" maxlength="255" class="col-md-4"/>
                    <span class="help-inline">栏目超链接地址，优先级“高”</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">目标:</label>
                <div class="col-md-8">
                    <form:input path="target" htmlEscape="false" maxlength="255" class="col-md-4"/>
                    <span class="help-inline">栏目超链接打开的目标窗口，新窗口打开，请填写：“_blank”</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">关键字:</label>
                <div class="col-md-8">
                    <form:input path="keywords" htmlEscape="false" maxlength="255" class="col-md-4"/>
                    <span class="help-inline">填写描述及关键字，有助于搜索引擎优化</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">排序:</label>
                <div class="col-md-8">
                    <form:input path="sort" htmlEscape="false" maxlength="255" class="col-md-4"/>
                    <span class="help-inline">栏目的排列次序</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">在导航中显示:</label>
                <div class="col-md-8">
                    <form:radiobuttons path="inMenu" items="${fns:getDictList('show_hide')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
                    <span class="help-inline">是否在导航中显示该栏目</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">在导航中显示:</label>
                <div class="col-md-8">
                    <form:radiobuttons path="inList" items="${fns:getDictList('show_hide')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
                    <span class="help-inline">是否在分类页中显示该栏目的文章列表</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label" title="默认展现方式：有子栏目显示栏目列表，无子栏目显示内容列表">展现方式:</label>
                <div class="col-md-8">
                    <form:radiobuttons path="showModes" items="${fns:getDictList('cms_show_modes')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
                    <span class="help-inline">默认展现方式：有子栏目显示栏目列表，无子栏目显示内容列表</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">是否允许评论:</label>
                <div class="col-md-8">
                    <form:radiobuttons path="allowComment" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 no-padding-right control-label">是否需要审核:</label>
                <div class="col-md-8">
                    <form:radiobuttons path="isAudit" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                </div>
            </div>
            <div class="form-actions">
                <div class="col-md-offset-2">
                    <shiro:hasPermission name="sys:user:edit"><input id="btnSubmit" class="btn btn-primary" type="button" value="保 存"/>&nbsp;</shiro:hasPermission>
                    <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
                </div>
            </div>
        </form:form>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $("#btnSubmit").click(function(){
            if($("#inputForm").valid()){
                $.post("${ctx}/cms/category/save", $("#inputForm").serialize(),function(data){
                    if(data.success){
                        showNote("success", function () {
                            window.location.href = "${ctx}/cms/category/list";
                        }, "操作成功");
                    }else {
                        showNote("error",function(){return false;},data.msg);
                    }
                });
            }else{
                showNote("error",function(){return false;},"输入有误，请正确输入数据","center");
            }
        });
    });
</script>
</body>
</html>
